package com.dongdongshop.test;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class test {

        public static int countConcatenation(String[] strings) {
            return countConcatenationHelper(strings, 0, strings.length - 1);
        }

        private static int countConcatenationHelper(String[] strings, int start, int end) {
            if (start == end) {
                return 1;
            } else if (start + 1 == end) {
                return 2;
            } else { int count = 0; for (int i = start; i < end; i++) {
                int leftCount = countConcatenationHelper(strings, start, i);
                int rightCount = countConcatenationHelper(strings, i + 1, end);
                count += leftCount * rightCount; } return count;
            }
        }
        public static void main(String[] args) {
            String[] strings = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
            int count = countConcatenation(strings);
            System.out.println("Total number of concatenation methods: 一共有" + count+"种");
            log.info("Total number of concatenation methods: 一共有"+count+"种");
        }

}
